package com.example.websocket.config.core.json.extender.impl;

import com.example.websocket.config.core.json.extender.FieldExtender;
import com.example.websocket.services.DictDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 用户扩展器
 */
@Component
@Slf4j
public class DictDataExtender implements FieldExtender {
    @Autowired
    private DictDataService dictDataService;

    @Override
    public Object extend(Object value) {
        if (value != null) {
            Integer id = (Integer) value;
            String name = dictDataService.getDictDataName(id);
            return name;
        }
        return null;
    }
}
